package com.gopay.scheduler.dao.qulifications.impl;

import com.gopay.common.base.dao.impl.BaseReadDAOImpl;
import com.gopay.scheduler.dao.qulifications.OverQualificationsInfoReadDao;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * CLASSNAME:OverQualificaitonsInfoReadDaoImpl
 * Description:过期资质统计类，包含统计营业执照过期和法人证件过期方法
 * DATE:2017/5/4/004
 * AUTHER:PANSHICHAO
 * www.gopay.com.cn Inc.All rights reserved.
 */
@Component("overQualificationsInfoReadDao")
public class OverQualificaitonsInfoReadDaoImpl extends BaseReadDAOImpl<Object[],String> implements OverQualificationsInfoReadDao{
    @Override
    public List<Object[]> getAllBusinessTermOverQualificationsInfo(Date nowDate,Date endDate) {
        String sql ="SELECT CUST_ID，CORP_NAME,EMAIL,BUSINESS_TERM,IS_MERCHANT FROM\n" +
                "CUST_CORP_INFO\n"+
                "where BUSINESS_TERM >= trunc(:startDate) and BUSINESS_TERM < trunc(:endDate) and IS_REAL_NAME_CERTIFY = '1' order by BUSINESS_TERM";

        Map<String,Object> param = new HashMap<String,Object>();
        param.put("startDate",nowDate);
        param.put("endDate",endDate);
        List<Object[]> resultList = super.findBySql(sql,param);
        if(resultList == null || resultList.size() == 0){
            return null;
        }else{
            return resultList;
        }
    }

    @Override
    public List<Object[]> getAllLegalPersonCertTermOverQualificationsInfo(Date nowDate,Date endDate) {
        String sql ="SELECT CUST_ID，CORP_NAME,EMAIL,LEGAL_PERSON_CERT_TERM,IS_MERCHANT FROM\n" +
                "CUST_CORP_INFO\n"+
                "where LEGAL_PERSON_CERT_TERM >= trunc(:startDate) and LEGAL_PERSON_CERT_TERM <trunc(:endDate) and IS_REAL_NAME_CERTIFY = '1' order by LEGAL_PERSON_CERT_TERM";

        Map<String,Object> param = new HashMap<String,Object>();
        param.put("startDate",nowDate);
        param.put("endDate",endDate);
        List<Object[]> resultList = super.findBySql(sql,param);
        if(resultList == null || resultList.size() == 0){
            return null;
        }else{
            return resultList;
        }
    }
}
